import serve from '@/utils/server'

export interface ShopItemData {
  data: any
  price: number
  spuSaleAttrList: spuSaleAttrList[]
  skuInfo: skuInfo[]
}

export interface skuInfo {
  id: number
  spuId: number
  price: number
  skuName: string
  skuDesc: string
  weight: number
  tmId: number
  category3Id: number
  skuDefaultImg: string
  isSale: number
  ShopImg: ShopImg[]
}

export interface spuSaleAttrList {
  id: number
  spuId: number
  baseSaleAttrId: number
  saleAttrName: string
  spuSaleAttrValueList: spuSaleAttrValueList[]
}

export interface ShopImg {
  id: number
  skuId: number
  imgName: string
  imgUrl: string
  spuImgId: number
  isDefault: number
}

export interface spuSaleAttrValueList {
  id: number
  spuId: number
  baseSaleAttrId: number
  saleAttrValueName: string
  saleAttrName: string
  isChecked: string
}

// 发请求

export default {
  // GET /admin/product/findBySpuId/{spuId}
  getShopItem(spuId: number) {
    return serve.get<any, ShopItemData>(`api/item/${spuId}`)
  },

  // /api/cart/addToCart/{ skuId }/{ skuNum }

  postShopItem(skuId: number, skuNum: number) {
    return serve.post<any, null>(`/api/cart/addToCart/${skuNum}/${skuId}`)
  }
}
